<script lang="ts" setup>
import Motion from "@/utils/motion";

defineOptions({
  name: "Empty"
});


const {emptyType} = defineProps({
  emptyType : {
    type: String,
    default: ()=>'userEmpty'
  }
})

const getAssetsFile = (url: string, type = 'png') => {
  const path = `/src/assets/emptys/${url}.${type}`;
  const modules: Record<string, any> = import.meta.glob(`@/assets/emptys/**/*.{png,svg,jpg,jpeg}`, { eager: true });
  if (modules[path]) return modules[path].default;
  else {
    // 地址错误
    console.error("Error url is wrong path");
  }
}
</script>

<template>
  <Motion class="empty">
    <img :src="getAssetsFile(emptyType)" alt="空"></img>
  </Motion>
</template>
<style lang="scss" scoped>
.empty {
  width: 160px;
  height: 160px;

  img {
    width: 100%;
    height: 100%;
  }
}
</style>
